import { handleActions } from "redux-actions"
import { SK_GET_SECONDKILL,SK_SET_CUR_PAGE,SK_SET_EACH_PAGE} from "../types"
import _ from "lodash"

const initDate = {
    curPage: 1,
    eachPage: 10,
    total: 0,
    maxPage: 0,
    rows: []
}

//返回操作student的reducer
export const secondKill = handleActions({
    //创建get学生的函数
    [SK_GET_SECONDKILL]: (state, { payload }) => {
        const { total, maxPage, rows } = payload;
        //_assign 参数3覆盖参数2state，参数2state交给参1{}
        return _.assign({}, state, {
            total, maxPage, rows
        })
    },
    [SK_SET_CUR_PAGE]: (state, { payload }) => {
        const { curPage } = payload;
        console.log(payload);
        const $state = _.clone(state);
        $state.curPage = curPage;
        return $state
    },
    [SK_SET_EACH_PAGE]: (state, { payload }) => {
        const { eachPage } = payload;
        console.log(payload);
        const $state = _.clone(state);
        $state.eachPage = eachPage;
        $state.rows=[];
        return $state
    },

    



}, initDate)